<?php
/**
 * Created by PhpStorm.
 * User: 65736
 * Date: 2019/3/24 0024
 * Time: 23:26
 */

namespace app\common\widget;


class WidgetCKeditor extends WidgetTextArea
{
    /**
     * 编辑器容器
     * @var WidgetTextArea
     */
    private $textArea;


    /**
     * 构造方法, 渲染挂件
     * @return mixed
     * @throws \think\Exception
     */
    function render()
    {
        // Before Render
        $this->beforeRender();
        // 分配数据
        self::$view->assign('textArea', $this->textArea);
        return $this->fetch();
    }

    /**
     * Before Render
     * @throws \think\Exception
     */
    private function beforeRender() {
        // 设置容器属性
        $domAttrs = $this->domAttrs;
        $this->textArea->setDomAttrList($domAttrs)
            ->setClass( $this->getClass() );
        $this->textArea = $this->textArea->render();
    }

    /**
     * 初始化函数
     * @throws \think\Exception
     */
    protected function initialize()
    {
        parent::initialize();
        // 初始化容器
        $this->textArea = new WidgetTextArea();
    }

}